//
//  getStringOfHeightOfReact.m
//  代码布局
//
//  Created by iOS on 16/7/27.
//  Copyright © 2016年 iOS. All rights reserved.
//

#import "getStringOfHeightOfReact.h"

@implementation getStringOfHeightOfReact
+(CGFloat)getstringHeight:(NSString*)string AndStringFont:(NSInteger)font AndLineSpace:(CGFloat)lineSpace andStringWidth:(CGFloat)width{
    NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init];
  
    paragraph.lineSpacing = lineSpace;
    
    NSDictionary *dic = @{
                          NSFontAttributeName : [UIFont systemFontOfSize:font],
                          NSKernAttributeName : @1,//字句调整
                          NSParagraphStyleAttributeName : paragraph
                          };
//    [string addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:font] range:NSMakeRange(0, string.length)];
//    [string addAttribute:NSParagraphStyleAttributeName value:paragraph range:NSMakeRange(0, string.length)];
   // NSString * string1 = [NSString stringWithFormat:@"%@",string];
    CGRect frame = [string boundingRectWithSize:CGSizeMake(width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
 //   CGRect frame = [string boundingRectWithSize:CGSizeMake(width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin context:nil];
    //NSLog(@"-------%.1f",frame.size.height);
    return frame.size.height;


}
+(CGSize)getstring:(NSString*)string AndFont:(CGFloat)font{
    NSDictionary *attrs1 = @{NSFontAttributeName : [UIFont systemFontOfSize:font]};
    CGSize size1 = [string boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs1 context:nil].size;
    return size1;
}
@end
